/*
package net.yla.smartbus.core.util;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import net.yla.smartbus.module.ba.log.service.LogService;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Properties;

*/
/**
 * 日志mybatis 拦截器 功能为拦截数据库操作，获取操作类型及操作表格，并从CustomContext获取线程变量中的数据封装日志
 * 比较粗糙，下次优化
 * Signature 对Executor 的 update 及query 方法进行拦截，后面为参数
 *
 * @author wangqichang
 * @see
 * @since 2019/5/20
 *//*

@Component
@Slf4j
@Intercepts({@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}),
        @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class})
})

public class LogInterceptor implements Interceptor {

    private static String LOG_TYPE = "操作日志";

    */
/**
     * 这个是日志服务，使用feign调用
     *//*



    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        //仅做日志，不能影响正常业务，故try住
        try {
            //获取第一个参数，就是Signature中args的下标
            MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
            */
/*LogDto logDto = new LogDto();*//*

            Date date = new Date();
            //获取第二个参数Object，这个对象可能是实体也可能是map，比如自己用@Param注入参数，那就是map对象
            Object object = invocation.getArgs()[1];
            if (!(object instanceof Map)) {
                //直接记录操作的实体
               */
/* logDto.setOperationEntity(object.getClass().getName());*//*

                System.out.println(object.getClass().getName());
            } else {
                //如果是注入的map参数，则使用jsqlphaser提取表名
                String sql = mappedStatement.getBoundSql(object).getSql();
                List<String> tableNames = SqlTableUtil.getTableNames(sql);
                String tables = CollUtil.join(tableNames, " ");
                */
/*logDto.setOperationEntity(tables);*//*

            }
            String dateTime = DateUtil.formatDateTime(date);
            String operationType = null;
            switch (mappedStatement.getSqlCommandType()) {
                case INSERT:
                    operationType = "新增";
                    break;
                case UPDATE:
                    operationType = "更新";
                    break;
                case DELETE:
                    operationType = "删除";
                    break;
                case SELECT:
                    operationType = "查询";
                    break;
                default:
                    operationType = "未知";
                    break;
            }
            System.out.println(operationType+"0000000000000000");
            System.out.println(date);
            System.out.println(LOG_TYPE);
            */
/*StringBuilder logDesc = new StringBuilder().append("用户 ").append(info.getNickName()).append(" 于 ").append(dateTime).append(" 对 ").append(logDto.getModuleName()).append(" 模块进行了 ").append(operationType).append(" 操作");
            logDto.setOperationType(operationType);
            logDto.setCreateTime(date);
            logDto.setLogType(LOG_TYPE);
            logDto.setLogDesc(logDesc.toString());
            logService.recordLog(logDto);*//*

        } catch (Exception e) {
            log.error("日志记录出错，错误信息：{}", e.getMessage());
            e.printStackTrace();
        }
        //放行拦截
        return invocation.proceed();
    }

    @Override
    public Object plugin(Object target) {
        return Plugin.wrap(target, this);
    }

    @Override
    public void setProperties(Properties properties) {
    }
}
*/
